// 导入axios库
import axios from 'axios'

/**
 * TodoAPI接口集合
 * @method getSiteByPolygon(keywords) 通过范围搜索获取位置   参数:keywords---搜索关键字
 * @method getTrafficByRoad() 通过路名获取实时路况    getTrafficByRoad()
 */
/*  在.vue中使用demo:
      // 1. 导入
      import todosApi from '@/apis/todos.js'
      // 2. 调用
      todosApi.getAll().then((res) => {
        console.log(res)
      })
*/
class todosApi {
  getSiteByPolygon(keywords) {
    return axios.get(
      `http://api.tianditu.gov.cn/v2/search?postStr={"keyWord":"${keywords}","polygon":"114.321103824701,
      30.4603819425023,
      114.417985401979,
      30.4603819425023,
      114.417985401979,
      30.5289618107912,
      114.321103824701,
      30.5289618107912,
      114.321103824701,
      30.4603819425023","queryType":10,"start":0,"count":10}&type=query&tk=0da1e30f2bca0840c0a4ac19869a6d99`
    )
  }
  getTrafficByRoad() {
    return service.get('/todos')
  }
}

export default new todosApi()
